﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DAO;
using DTO;

namespace QLDaiLy
{
    public partial class BaoCaoDoanhSo :XtraUserControl
    {
        public BaoCaoDoanhSo()
        {
            InitializeComponent();
          //  loadBaoCaoTheoThang();
            fillMonthCombobox();
            //loadBaoCaoTheoThang();
        }
        private void loadBaoCaoTheoThang()
        {
            string thang = cbbThang.EditValue.ToString();
           // string thangBaoCao = dateThangBaoCao.Text;
            List<BaoCaoDoanhSoDTO> dt = BaoCaoDoanhSoDAO.baoCaoTheoThang(thang);
            gridControlBaoCaoDoanhSo.DataSource = dt;
        }
        private void fillMonthCombobox()
        {
            // int year = DateTime.Now.Year;
            for (int i = 1; i <= 12; i++)
            {
                cbbThang.Properties.Items.Add(i);
            }
            cbbThang.SelectedIndex = -1;
            // cbbThangTu.Properties.Sorted = true;

        }
        private void btnBaoCaoDoanhSo_Click(object sender, EventArgs e)
        {
            if (gridViewBaoCaoDoanhSo.RowCount > 0)
            {
                FrmReport frm = new FrmReport();
                frm.ShowDialog();
                frm.Dispose();
            }
        }

        private void cbbThang_SelectedValueChanged(object sender, EventArgs e)
        {
            loadBaoCaoTheoThang();
        }

        private void dateThangBaoCao_EditValueChanged(object sender, EventArgs e)
        {
            loadBaoCaoTheoThang();
        }

        private void gridViewBaoCaoDoanhSo_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column == STT)
            {
                e.DisplayText = Convert.ToString(e.RowHandle + 1);
            }
        }   
    }
}
